package com.java.learning.cha1;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;

public class FileOutputStreamDemo {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream("D:\\mytest.txt");
            System.out.println("请输入内容：");
            String str = scanner.nextLine();
            fos.write(str.getBytes());
            System.out.println("已保存");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
